import { defineStore } from "pinia";
import { Names } from "../../store-namespace";
import { _get, _post, _put, _delete, http } from "@/utils/axios";
import { FollowProlem } from "@/api/backend/index";

export const useFollowProlem = defineStore(Names.FollowProlem, {
  state: () => {
    return {
      single: <any>{},
      type: <any>[], //问题域的字典
      statusType: <any>[], //晨会问题状态的字典
      tags: <any>{},
    };
  },
  getters: {},
  actions: {
    //获取晨会问题跟踪列表数据
    getList(filter: any) {
      return new Promise((resolve, reject) => {
        _get(FollowProlem + "/list", filter, "json", "")
          .then((res: any) => {
            console.log("获取晨会问题跟踪列表数据", res);
            resolve(res);
          })
          .catch((err: any) => {
            console.log(err);
            reject(err);
          });
      });
    },
    // 新增晨会问题跟踪数据
    add(data: any) {
      return new Promise((resolve, reject) => {
        _post(FollowProlem, data, "json", "")
          .then((res: any) => {
            console.log("新增晨会问题跟踪数据", res);
            resolve(res);
          })
          .catch((err: any) => {
            console.log(err);
            reject(err);
          });
      });
    },
    //编辑晨会问题跟踪数据
    edit(data: any) {
      return new Promise((resolve, reject) => {
        _put(FollowProlem, data, "json", "")
          .then((res: any) => {
            console.log("编辑晨会问题跟踪数据", res);
            resolve(res);
          })
          .catch((err: any) => {
            console.log(err);
            reject(err);
          });
      });
    },
  },
});
